var hosrId=null;
var hosrName=null;
var hosrIdcar=null;
var hosrMedical=null;
var hosrPhone=null;
var hosrSelfprice=null;
var hosrSex=null;
var hosrAge=null;
var hosrLookdoctor=null;
var pId=null;
var dId=null;
var hosrRemark=null;
var bId=null;
var cId=null;

$(function(){
	$("#hosrId").blur(function(){
		//alert();
		hosrId = $("#hosrId").val();
		$.ajax({
			type:"GET",
			url:"zhuyuanadd.do",
			data:"hosrId="+hosrId,
			datatype:"json",	
			success:function(data){
				//alert(data.key.hosrSelfprice.equal("0"));
				$("#hosrName").val(""+data.key.hosrName+"");
				$("#hosrName").val(""+data.key.hosrName+"");
				$("#hosrIdcar").val(""+data.key.hosrIdcar+"");
				$("#hosrMedical").val(""+data.key.hosrMedical+"");
				$("#hosrPhone").val(""+data.key.hosrPhone+"");
				//$("#hosrSelfprice").html("<span>"+是+"<span>");
				//alert(data.key.hosrSelfprice==0);
				if(data.key.hosrSelfprice==0){
					$("#hosrSelfprice").val("0");
					$("#Selfprice").html("是");
				}else{
					$("#hosrSelfprice").val("1");;
					$("#Selfprice").html("否");
				}
				if(data.key.hosrSex==0){
					$("#hosrSex").val("0");
					$("#Sex").html("男");
				}else{
					$("#hosrSex").val("1");
					$("#Sex").html("女");
				}
				$("#hosrAge").val(""+data.key.hosrAge+"");
				if(data.key.hosrLookdoctor==0){
					$("#hosrLookdoctor").val("0");
					$("#Lookdoctor").html("初诊");
				}else{
					$("#hosrLookdoctor").val("1");
					$("#Lookdoctor").html("初诊");
				}
				$("#pId").val(""+data.key.pId+"");
				$("#pId").html(""+data.key.pName+"");
				$("#dId").val(""+data.key.dId+"");
				$("#dId").html(""+data.key.dName+"");
				$("#hosrRemark").val(""+data.key.hosrRemark+"");
			}
		});
	});
	
	//护理
	$.ajax({
		type:"GEt",
		url:"addcid.do",
		dataType:"json",
		success:function(data){
			var cid = $("#cid").val();
			var oc = "<option value=\"0\">--请选择--</option>";
			for(var i=0;i<data.key.length;i++){
				if(cid!=null && cid!=undefined && data.key[i].caId==cid){
					oc +="<option value=\""+data.key[i].caId+"\" selected=\"selected\">"+data.key[i].caName+"</option>";
				}else{
					oc += "<option value=\""+data.key[i].caId+"\">"+data.key[i].caName+"</option>";
				}
			}
			$("#cId").html(oc);
		}
	});
	
	//床位
	$.ajax({
		type:"GET",
		url:"addbid.do",
		//data:"",
		dataType:"json",
		success:function(data){
			var bid = $("#bid").val();
			var op = "<option value=\"0\">--请选择--</option>";
			for(var i=0;i<data.key.length;i++){
				if(bid!=null && bid!=undefined && data.key[i].beId==bid){
					op += "<option value=\""+data.key[i].beId+"\" selected=\"selected\">"+data.key[i].beName+"</option>"
				}else{
					op += "<option value=\""+data.key[i].beId+"\">"+data.key[i].beName+"</option>";
				}
			}
			$("#bId").html(op);
		}
	});
	
});